<script setup lang="ts">
import { computed, withDefaults } from 'vue'

defineExpose({
  name: 'SelfWord'
})

const props = withDefaults(defineProps<{
  message: string | number | undefined,
  src: string | undefined
}>(), {})
</script>

<template>
  <!-- 自己消息 -->
  <div class="myself-message-box">
    <!-- 头像 -->
    <div class="avatar-box">
      <img class="avatar" :src="src || '../public/images/avatar/avatar-220.jpg'" alt="">
    </div>
    <!-- 对方聊天消息框 -->
    <div class="myself-message relative">
      <!-- word文件消息盒子 -->
      <div class="word-box flex">
        <div class="left">
          <div class="title">{{ props.message }}.docx</div>
          <div class="size">127K</div>
        </div>
        <div class="right">
          <img class="word-icon" src="../../public/images/word-icon.png" alt="">
        </div>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.myself-message-box {
  display: flex;
  justify-content: end;
  flex-direction: row-reverse;
  margin-bottom: $message-message-space;
  font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;

  .avatar-box {
    overflow: hidden;
    width: $avatar-size;
    height: $avatar-size;
    border-radius: $avatar-radius;
    margin-left: $avatar-message-space;

    .avatar {
      width: $avatar-size;
      border-radius: $avatar-radius;
      height: $avatar-size;
      object-fit: cover;
    }
  }
}

.word-box {
  background-color: #fff;
  border-radius: $message-box-radius;
  width: 246px;
  padding: $message-box-padding;
  display: flex;

  .left {
    flex: 1;

    .title {
      //color: $self-message-color;
      // 字体描边实现加粗
      -webkit-text-stroke: 0.2px currentColor;
    }

    .size {
      font-size: 12px;
      color: #878787;
    }
  }

  .right {
    .word-icon {
      width: 36px;
      margin-right: 5px;
    }
  }

  &:after {
    content: '';
    position: absolute;
    right: -11px;
    top: 15px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-left: 6px solid #fff;
  }
}
</style>